<?php

/**
 * This class is used to provide basic configuration for the whole application.
 */
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    /**
     * Make the configuration visible in the whole application.
     */
    protected function _initConfig()
    {
	$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
	Zend_Registry::set('config', $config);
    }

    /**
     * Initialize class autoloading.
     */
    protected function _initAutoload()
    {
	new Zend_Application_Module_Autoloader(array(
		    'namespace' => '',
		    'basePath' => APPLICATION_PATH));

	$autoloader = Zend_Loader_Autoloader::getInstance();
	$autoloader->registerNamespace('Fkb_');
	if ("testing" != APPLICATION_ENV)
	{
	    require_once 'dompdf_config.inc.php';
	    $autoloader->pushAutoloader('DOMPDF_autoload');
	}
    }

    /**
     * Initialize view parameters.
     */
    protected function _initDoctype()
    {
	$this->bootstrap('view');
	$view = $this->getResource('view');
	$view->doctype('HTML5');
	$view->setEncoding('UTF-8');
	$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
	
    }

    protected function _initTranslation()
    { 
	$translator = new Zend_Translate(
	    'array',
	    APPLICATION_PATH . '/../resources/languages',
	    'de',
	    array('scan' => Zend_Translate::LOCALE_DIRECTORY)
	);
	Zend_Validate_Abstract::setDefaultTranslator($translator); 
    }
    
    /**
     * Initialize access control.
     */
    protected function _initAccessControl()
    {
	$aclHelper = new Fkb_Controller_Action_Helper_Acl(null, array('acl' => new Fkb_Acl()));
	Zend_Controller_Action_HelperBroker::addHelper($aclHelper);
    }

    /**
     * init jquery view helper, enable jquery, jqueryui, jquery ui css
     */
    protected function _initJquery()
    {

	$this->bootstrap('view');
	$view = $this->getResource('view'); //get the view object
	//add the jquery view helper path into your project
	$view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");

	//jquery lib includes here (default loads from google CDN)
	$view->jQuery()->enable()//enable jquery ; ->setCdnSsl(true) if need to load from ssl location
		->setLocalPath('/libs/jquery-ui-1.9.2.custom/js/jquery-1.8.3.js')
		->setUILocalPath('/libs/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js')
		->setVersion('1.8.3')//jQuery version, automatically 1.5 = 1.5.latest
		->setUiVersion('1.9.2')//jQuery UI version, automatically 1.8 = 1.8.latest
		->addStylesheet('/libs/jquery-ui-1.9.2.custom/css/ui-lightness/jquery-ui-1.9.2.custom.min.css')//add the css
		->uiEnable(); //enable ui
    }

    protected function _initPlaceholders()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');
       
        // Setzt das initiale Stylesheet:
        //$view->headLink()->prependStylesheet('/styles/site.css');
 
        // Setzt das initiale JS das geladen werden soll:
        $view->headScript()->prependFile('/libs/js/event/dialog.js');
    }
}
